package com.young.cloud.gateway.filter;

import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;
import com.netflix.zuul.exception.ZuulException;
import com.young.common.util.CommonConstants;
import com.young.common.util.CommonUtil;
import com.young.common.util.StringUtils;
import org.slf4j.MDC;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 公共的后置处理过滤器
 * Created by Administrator on 2019/12/28 0028.
 */
@Component
public class CommonPostFilter extends ZuulFilter {
    @Override
    public String filterType() {
        return "post";
    }

    @Override
    public int filterOrder() {
        return 10;
    }

    @Override
    public boolean shouldFilter() {
        return true;
    }

    @Override
    public Object run() throws ZuulException {
        //清除traceId
        MDC.remove(CommonConstants.TRACE_KEY);
        return null;
    }
}
